/**
 * EditCourseInfoForm class.
 */
package pits.form;

import java.util.ArrayList;
import java.util.List;

import javax.portlet.ActionRequest;

import pits.util.Errand;

public class EditCourseInfoForm {

	private int courseID;
	private String courseName;
	private String description;
	private int companyID;
	private String department;
	private String dateIssused;
	private List<String> langNames;
	private List<Integer> langIDs;
	private List<String> appNames;
	private List<Integer> appIDs;
	private List<String> techNames;
	private List<Integer> techIDs;
	private List<String> frameNames;
	private List<Integer> frameIDs;

	public EditCourseInfoForm(String txtCourseID) {
		courseID = Integer.parseInt(txtCourseID);
	}

	/**
	 * @return list of errors if exist
	 */
	public List<String> validate() {

		List<String> errorMess = new ArrayList<String>();

		return errorMess;
	}

	/**
	 * @param request
	 */
	public void setFields(ActionRequest request) {
		try {
			Errand errand = new Errand();

			if (request.getParameter("courseName") != null) {
				setCourseName(request.getParameter("courseName"));
			}
			if (request.getParameter("description") != null) {
				setDescription(request.getParameter("description"));
			}
			if (request.getParameter("companyID") != null) {
				setCompanyID(Integer.parseInt(request.getParameter("companyID")));
			}
			if (request.getParameter("department") != null) {
				setDepartment(request.getParameter("department"));
			}
			if (request.getParameter("dateIssused") != null) {
				setDateIssused(errand.parseDate(request.getParameter("dateIssused").toString()));
			}

			/**
			 * Language list
			 */
			List<Integer> langIDs = new ArrayList<Integer>();
			List<String> langNames = new ArrayList<String>();

			if (request.getParameter("language") != null) {
				// new pits.util.Logger().write(request.getParameter("language")
				// + "_");
				errand.parseNameID(request.getParameter("language").split(":"), langIDs, langNames);
			}

			setLangIDs(langIDs);
			setLangNames(langNames);

			/**
			 * Application list
			 */
			List<Integer> appIDs = new ArrayList<Integer>();
			List<String> appNames = new ArrayList<String>();

			if (request.getParameter("application") != null) {
				// new
				// pits.util.Logger().write(request.getParameter("application")
				// + "_");
				errand.parseNameID(request.getParameter("application").split(":"), appIDs, appNames);
			}

			setAppIDs(appIDs);
			setAppNames(appNames);

			/**
			 * Technology list
			 */
			List<Integer> techIDs = new ArrayList<Integer>();
			List<String> techNames = new ArrayList<String>();

			if (request.getParameter("technology") != null) {
				// new
				// pits.util.Logger().write(request.getParameter("technology") +
				// "_");
				errand.parseNameID(request.getParameter("technology").split(":"), techIDs, techNames);
			}

			setTechIDs(techIDs);
			setTechNames(techNames);

			/**
			 * Framework list
			 */
			List<Integer> frameIDs = new ArrayList<Integer>();
			List<String> frameNames = new ArrayList<String>();

			if (request.getParameter("framework") != null) {
				// new
				// pits.util.Logger().write(request.getParameter("framework") +
				// "_");
				errand.parseNameID(request.getParameter("framework").split(":"), frameIDs, frameNames);
			}

			setFrameIDs(frameIDs);
			setFrameNames(frameNames);
		} catch (Exception e) {
			new pits.util.Logger().write(e.toString());
		}
		new pits.util.Logger().write("EditCourseInfoForm.setFields: Done");
	}

	/**
	 * @return the courseID
	 */
	public int getCourseID() {
		return courseID;
	}

	/**
	 * @param courseID
	 *            the courseID to set
	 */
	public void setCourseID(int courseID) {
		this.courseID = courseID;
	}

	/**
	 * @return the courseName {
	 */
	public String getCourseName() {
		return courseName;
	}

	/**
	 * @param courseName
	 *            the courseName to set
	 */
	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	/**
	 * @return the descripition
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param descripition
	 *            the descripition to set
	 */
	public void setDescription(String descripition) {
		this.description = descripition;
	}

	/**
	 * @return the companyID
	 */
	public int getCompanyID() {
		return companyID;
	}

	/**
	 * @param companyID
	 *            the companyID to set
	 */
	public void setCompanyID(int companyID) {
		this.companyID = companyID;
	}

	/**
	 * @return the departmentID
	 */
	public String getDepartment() {
		return department;
	}

	/**
	 * @param departmentID
	 *            the departmentID to set
	 */
	public void setDepartment(String department) {
		this.department = department;
	}

	/**
	 * @return the dateIssused
	 */
	public String getDateIssused() {
		return dateIssused;
	}

	/**
	 * @param dateIssused
	 *            the dateIssused to set
	 */
	public void setDateIssused(String dateIssused) {
		this.dateIssused = dateIssused;
	}

	/**
	 * @return the langNames
	 */
	public List<String> getLangNames() {
		return langNames;
	}

	/**
	 * @param langNames
	 *            the langNames to set
	 */
	public void setLangNames(List<String> langNames) {
		this.langNames = langNames;
	}

	/**
	 * @return the langIDs
	 */
	public List<Integer> getLangIDs() {
		return langIDs;
	}

	/**
	 * @param langIDs
	 *            the langIDs to set
	 */
	public void setLangIDs(List<Integer> langIDs) {
		this.langIDs = langIDs;
	}

	/**
	 * @return the appNames
	 */
	public List<String> getAppNames() {
		return appNames;
	}

	/**
	 * @param appNames
	 *            the appNames to set
	 */
	public void setAppNames(List<String> appNames) {
		this.appNames = appNames;
	}

	/**
	 * @return the appIDs
	 */
	public List<Integer> getAppIDs() {
		return appIDs;
	}

	/**
	 * @param appIDs
	 *            the appIDs to set
	 */
	public void setAppIDs(List<Integer> appIDs) {
		this.appIDs = appIDs;
	}

	/**
	 * @return the techNames
	 */
	public List<String> getTechNames() {
		return techNames;
	}

	/**
	 * @param techNames
	 *            the techNames to set
	 */
	public void setTechNames(List<String> techNames) {
		this.techNames = techNames;
	}

	/**
	 * @return the techIDs
	 */
	public List<Integer> getTechIDs() {
		return techIDs;
	}

	/**
	 * @param techIDs
	 *            the techIDs to set
	 */
	public void setTechIDs(List<Integer> techIDs) {
		this.techIDs = techIDs;
	}

	/**
	 * @return the frameNames
	 */
	public List<String> getFrameNames() {
		return frameNames;
	}

	/**
	 * @param frameNames
	 *            the frameNames to set
	 */
	public void setFrameNames(List<String> frameNames) {
		this.frameNames = frameNames;
	}

	/**
	 * @return the frameIDs
	 */
	public List<Integer> getFrameIDs() {
		return frameIDs;
	}

	/**
	 * @param frameIDs
	 *            the frameIDs to set
	 */
	public void setFrameIDs(List<Integer> frameIDs) {
		this.frameIDs = frameIDs;
	}
}
